<template>
  <div class="head-container">
    <!-- 搜索 -->
    <el-input v-model="query.typename" clearable placeholder="类型" style="width: 160px;" class="filter-item" @keyup.enter.native="toQuery" />
    <el-input v-model="query.sparepartname" clearable placeholder="名称" style="width: 160px;" class="filter-item" @keyup.enter.native="toQuery" />
    <el-select
      v-model="query.sparepartbrand"
      clearable
      style="width: 160px;"
      class="filter-item"
      placeholder="品牌"
      @change="toQuery"
    >
      <el-option
        v-for="(item, index) in brandList"
        :key="item.label + index"
        :label="item.label"
        :value="item.value"
      />
    </el-select>
    <el-select
      v-model="query.spareparttmodel"
      clearable
      style="width: 160px;"
      class="filter-item"
      placeholder="型号"
      @change="toQuery"
    >
      <el-option
        v-for="(item, index) in modelList"
        :key="item.label + index"
        :label="item.label"
        :value="item.value"
      />
    </el-select>
    <el-select
      v-model="query.state"
      clearable
      style="width: 160px;"
      class="filter-item"
      placeholder="状态"
      @change="toQuery"
    >
      <el-option
        v-for="(item, index) in SPARE_STATES"
        :key="item.name + index"
        :label="item.name"
        :value="item.id"
      />
    </el-select>
    <el-button class="filter-item" size="mini" type="success" icon="el-icon-search" @click="toQuery">搜索</el-button>
  </div>
</template>

<script>
import { SPARE_STATES } from '@/constants/consts'
export default {
  props: {
    query: {
      type: Object,
      required: true
    },
    eqptId: {
      type: Number,
      default: -1
    },
    supThis: {
      type: Object,
      required: true
    },
    brandList: {
      type: Array,
      required: true
    },
    modelList: {
      type: Array,
      required: true
    }
  },
  data() {
    return {
      SPARE_STATES
    }
  },
  methods: {
    toQuery() {
      this.$parent.page = 0
      this.$parent.init()
    },
    newSparepart() {
      this.$refs.form.dialog = true
      this.$refs.form.getSpareparttmodel()
      this.$refs.form.getSparepartBrand()
    }
  }
}
</script>
